expand    MACRO  source, sign, exponent, fraction
LOCAL  addOne, endAddOne
; take the 32-bit floating point value source and expand it into 
; separate pieces:
;   sign: byte
;   exponent: word (bias removed)
;   fraction: doubleword (with leading 1)
          push eax             ; save EAX
          mov  eax, source     ; get source
          rol  eax, 1          ; sign to bit 0
          mov  sign, 0         ; clear sign
          mov  sign, al        ; get byte with sign bit
          and  sign, 1         ; mask all but sign bit
          rol  eax, 8          ; shift exponent to bits 0-7
          mov  exponent, ax    ; get word with biased exponent
          and  exponent, 0ffh  ; mask all but exponent
          sub  exponent, 127   ; subtract bias
          shr  eax, 9          ; shift fraction to right
          test eax, eax        ; is fraction zero?
          jnz  addOne          ; add leading 1 bit if non-zero
          cmp  exponent, -127  ; was original exponent 0?
          je   endAddOne       ; if so, leave fraction at zero
AddOne:   or   eax, 800000h    ; add leading 1 bit
endAddOne:
          mov  fraction, eax   ; store fraction
          pop  eax             ; restore EAX
          ENDM

